package render;

import java.util.List;

import env.Env;
import env.cell.Cell;
import processing.core.PApplet;
import processing.core.PConstants;

public class Renderer {

	private static final int BGCOLOR = 0;
	private static final int FADE_FACTOR = 25; //15 is a good factor
	// parent applet
	private PApplet p;
	private Env env;
	
	public Renderer(PApplet p, Env env) {
		this.p = p;
		this.env = env;
		
		p.background(BGCOLOR);
	}

	public void display() {
		// iterate over all objs in Env
		// for their pos, translate, rotate;
		// render them (ignore animations at the moment)

		p.smooth();
		p.noStroke();

		p.fill(BGCOLOR, FADE_FACTOR);
		p.rect(0, 0, 800,600);
		
		// TODO can some things fade slow, others fade fast? e.g. i'd like some
		// watercolory side-effecct artefacts of objects to fade slowly, but
		// for motion-blur of movement to fade quickly
		/*
		 * if (r.nextFloat < 0.01) { p.fill(5,30,66) p.rect(40,40, 50, 60) }
		 */
		p.ellipseMode(PConstants.RADIUS);
		List<Cell> cells = env.getCells();
		for (Cell c : cells) {
			c.draw(p);
		}
	}
}
